#include <iostream>
#define PI 3.141

using namespace std;

// Static implementation of the factory design pattern

// Abstract class
class Shape{

public:

	// Static function to make objects
	static Shape* MakeShape(int Type);

	// Pure virtual function thats will get overridden
	virtual void GetType() = 0;

	int GetSize(){
		return Size;
	}

	void SetSize(int ValueSize){
		Size = ValueSize;
	}

private:
	int Size;
};


// Concrete sub-class
class Square : public Shape{

public:
	// friend class to the Shape class, this allows the Square class objects to acces the Shape 
	// class functions en methods (also the protected and private functions and fields)
	friend class Shape;

	void GetType(){
		cout << "Square" << endl;
	}

	int GetSize(){
		return Size = Size * Size;
	}

private:
	int Size;
};

// Concrete sub-Class
class Circle : public Shape{

public:
	friend class Shape;

	void GetType(){
		cout << "Circle" << endl;
	}

	int GetSize(){
		return Size = (int)PI * Size * Size;
	}

private:
	int Size;
};

// Static function to make objects
Shape* Shape::MakeShape(int Type){

	switch (Type)
	{
	case 1:
		return new Square();
		break;
	case 2:
		return new Circle();
		break;

	default:
		return NULL;
		break;
	}
}

